/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var koyomi = {};
koyomi.START_HEISEI = 1988;
koyomi.START_SHOWA = 1925;
koyomi.START_TAISHO = 1911;
koyomi.START_MEIJI = 1867;
koyomi.END_OF_PRIMARY_SCHOOL = 13;
koyomi.END_OF_JUNIOR_HIGH_SCHOOL = koyomi.END_OF_PRIMARY_SCHOOL + 3;
koyomi.END_OF_HIGH_SCHOOL = koyomi.END_OF_JUNIOR_HIGH_SCHOOL + 3;
koyomi.END_OF_University2 = koyomi.END_OF_HIGH_SCHOOL + 2;
koyomi.END_OF_University3 = koyomi.END_OF_HIGH_SCHOOL + 3;
koyomi.END_OF_University4 = koyomi.END_OF_HIGH_SCHOOL+4;
koyomi.NAME_OF_AN_ERA_HEISEI = "平成";
koyomi.NAME_OF_AN_ERA_SHOWA = "昭和";
koyomi.NAME_OF_AN_ERA_TAISHO = "大正";
koyomi.NAME_OF_AN_ERA_MEIJI = "明治";
koyomi.UNIT_JP_YEAR="年";

koyomi.seireki_to_wareki = function(argYear) {
    if (argYear > koyomi.START_HEISEI) {
        return (argYear - koyomi.START_HEISEI);
    }
    if (argYear > koyomi.START_SHOWA) {
        return (argYear - koyomi.START_SHOWA);
    }
    if (argYear > 1911) {
        return (argYear - koyomi.START_TAISHO);
    }
    if (argYear > 1867)
        return (argYear - koyomi.START_MEIJI);
};
koyomi.seireki_to_wareki = function(argYear) {
    if (argYear > koyomi.START_HEISEI) {
        return (argYear - koyomi.START_HEISEI);
    }
    if (argYear > koyomi.START_SHOWA) {
        return (argYear - koyomi.START_SHOWA);
    }
    if (argYear > koyomi.START_TAISHO) {
        return (argYear - koyomi.START_TAISHO);
    }
    if (argYear > koyomi.START_MEIJI)
        return (argYear - koyomi.START_MEIJI);
};
koyomi.year_to_age = function(argYear) {
    var myD = new Date();
    var currentYear = myD.getFullYear();
    return (currentYear - argYear);
};
koyomi.seireki_to_wareki_string = function(argYear) {
    if (argYear > koyomi.START_HEISEI) {
        return koyomi.NAME_OF_AN_ERA_HEISEI + (argYear - koyomi.START_HEISEI);
    }
    if (argYear > koyomi.START_SHOWA) {
        return koyomi.NAME_OF_AN_ERA_SHOWA + (argYear - koyomi.START_SHOWA);
    }
    if (argYear > koyomi.START_TAISHO) {
        return koyomi.NAME_OF_AN_ERA_TAISHO + (argYear - koyomi.START_TAISHO);
    }
    if (argYear > koyomi.START_MEIJI)
        return koyomi.NAME_OF_AN_ERA_MEIJI + (argYear - koyomi.START_MEIJI);
};

koyomi.year_to_primary_school = function(argYear) {
    return (argYear + koyomi.END_OF_PRIMARY_SCHOOL);
};
koyomi.year_to_junior_high_school = function(argYear) {
    return (argYear + koyomi.END_OF_JUNIOR_HIGH_SCHOOL);
};
koyomi.year_to_high_school = function(argYear) {
    return (argYear + koyomi.END_OF_HIGH_SCHOOL);
};
koyomi.year_to_university2 = function(argYear) {
    return (argYear + koyomi.END_OF_University2);
};
koyomi.year_to_university3 = function(argYear) {
    return (argYear + koyomi.END_OF_University3);
};
koyomi.year_to_university4 = function(argYear) {
    return (argYear + koyomi.END_OF_University4);
};
